<template>
    <div class="search_result">
        <mlist v-if="$route.query.type == '相关大师'" :masters="result[0].data"></mlist>
        <ques-item v-if="$route.query.type == '相关闪问'" v-for="(item, key) in result[1].data" :key="key" :item="item"></ques-item>
    </div>
</template>

<script>
    import mlist from '@/views/master/mlist';
    import quesItem from "@/components/quesItem";
    export default {
        name: 'searchResult',
        components: {
            mlist,
            quesItem
        },
        data() {
            return {
                result: [
                    {
                        classify: '相关大师',
                        num: 0,
                        data: []
                    },{
                        classify: '相关闪问',
                        num: 0,
                        data: []
                    }
                ],
            }
        },
        methods: {
            getmasterlist(keyword) {
                let params = {
                    keyword: keyword,
                    offset: 0,
                    limit: 1000
                }
                this.$http.fetchGet('getmasterlist', params).then(res => {
                    if(res.code == 200) {
                        this.result[0]['data'] = res.data
                    }
                })
            },
            relateFlashquizList(keyword) {
                let params = {
                    keyword: keyword,
                    limit: 1000
                }
                this.$http.fetchGet('relateFlashquizList', params).then(res => {
                    if(res.code == 200) {
                        this.result[1]['data'] = res.data
                        console.log(this.result[1]['data'])
                    }
                })
            },
        },
        mounted() {
            if(this.$route.query.type == '相关大师') this.getmasterlist(this.$route.query.kw)
            else if(this.$route.query.type == '相关闪问') this.relateFlashquizList(this.$route.query.kw)
        }
    }
</script>

<style>

</style>
